const userModel = require("../model/userModel")

module.exports = {
    login({ username, password }) {
        console.log(username, password)
        return userModel.findOne({ username: username, password: password }).populate("role")
    },
    add(data) {
        console.log(data)
        return userModel.create(data)
    },
    getList() {
        return userModel.find().populate("role")
    },
    update(id, data) {
        console.log(data)
        return userModel.findOneAndUpdate({ _id: id }, {
            $set: data
        })
    },
    delete(data) {
        console.log(data.id)
        return userModel.findOneAndDelete({ _id: data.id })
    }
}